home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7406 < prev    next >
Encoding:
Text File  |  1996-08-05  |  931 b   |  33 lines

  1. Path: fmsu03.fm.intel.com!vdalvi
  2. From: vdalvi@mcd.intel.com (Vishram Dalvi)
  3. Newsgroups: comp.lang.c
  4. Subject: Generating pointer to struct from string
  5. Date: 26 Feb 1996 06:31:44 GMT
  6. Organization: intel Corp
  7. Distribution: world
  8. Message-ID: <4grk4g$hep@fmsu03.fm.intel.com>
  9. NNTP-Posting-Host: fmwu34
  10. Originator: vdalvi@fmwu34
  11.  
  12. Hello,
  13.  
  14. Say I have 3 structs aaa, bbb and ccc of type foo:
  15.  
  16. struct foo {
  17.     int flag;
  18.     char name[30]
  19. } aaa, bbb, ccc;
  20.  
  21. I assign some values to the data members of all 3 structs. Now I prompt the
  22. user for the name of one of these structs. I read in the user entry into a
  23. char array. Assume that the user entered "aaa". How can I generate a pointer
  24. to the struct "aaa" from the user entry?
  25. I do not want a switch/case table (if user entered "aaa", access members of
  26. "aaa", if user entered "bbb"...).
  27. How do I cast a string into a struct address??
  28. Thanks in advance,
  29.  
  30. Vishram Dalvi
  31. (vdalvi@mcd.intel.com)
  32.  
  33.